﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Scheduler;

namespace Spotted.Views
{
    public partial class notifictions : PhoneApplicationPage
    {

        
       

        public notifictions()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            AddReminder();
            MessageBox.Show("Reminder was added successfully");
            if (this.NavigationService.CanGoBack)
            {
                this.NavigationService.GoBack();
            }

            
        }

        private void btnClear_Click(object sender, RoutedEventArgs e)
        {

        }


        void AddReminder()
        {
            try
            {
                Reminder reminder = new Reminder(txtName.Text.ToString());
                reminder.Content = txtContent.Text.ToString();
                DateTime date = (DateTime)datePicker1.Value;
                DateTime time = (DateTime)timePicker1.Value;
                DateTime beginTime = date + time.TimeOfDay;
                reminder.BeginTime = beginTime;
                DateTime end = date + time.AddMinutes(1).TimeOfDay;
                reminder.ExpirationTime = end;
                reminder.RecurrenceType = RecurrenceInterval.Yearly;
                ScheduledActionService.Add(reminder);
                
                
                

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }





        }
      
    }
}